package com.hxkcloud.patient.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hxkcloud.patient.R;

/**
 * Created by ray_lei on 2016/7/6.
 */
public class DepartmentForDNActivity extends BaseActivity implements View.OnClickListener {

    private LinearLayout titleLayout;
    private TextView titleTV;//标题
    private ImageView backIV;//回退按钮
    private TextView rightTV;//保存按钮

    private EditText departmentET;//所输入部门

    private String name;

    private int type = 2;//2科室3学校4单位

    @Override
    protected void updateByHandler(Message msg) {
        switch (msg.what) {

        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_layout_departmentfordn);
        name = this.getIntent().getStringExtra("name");
        type = this.getIntent().getIntExtra("type", 2);
        initView();
        initData();
        initListener();
    }

    @Override
    protected void initView() {

        titleLayout = (LinearLayout) findViewById(R.id.ll_title);
        setTitlePadding(titleLayout);

        titleTV = (TextView) findViewById(R.id.tv_title_title);
        if (type == 3) {
            titleTV.setText(R.string.certification_text_school);
        } else if (type == 4) {
            titleTV.setText(R.string.certification_text_company);
        } else {
            titleTV.setText(getResources().getString(R.string.personalinfofordn_text_department));
        }
        backIV = (ImageView) findViewById(R.id.iv_title_back);
        backIV.setVisibility(View.VISIBLE);
        rightTV = (TextView) findViewById(R.id.tv_title_func);
        rightTV.setText(getResources().getString(R.string.departmentfordn_save));
        rightTV.setVisibility(View.VISIBLE);

        departmentET = (EditText) findViewById(R.id.departmentfordn_et_dep);
        departmentET.setText(name);
    }

    @Override
    protected void initListener() {
        backIV.setOnClickListener(this);
        rightTV.setOnClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        {

            switch (v.getId()) {
                case R.id.iv_title_back:
                    finish();
                    break;

                case R.id.tv_title_func:
                    if (departmentET.getText().toString().trim() != null) {
                        Intent intent = new Intent();
                        intent.putExtra("name", departmentET.getText().toString().trim());
                        setResult(RESULT_OK, intent);
                        finish();
                    }
                    break;
            }

        }
    }
}
